package com.example.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.entity.Classification;
import com.example.entity.vo.ClassificationVo;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author jobob
 * @since 2024-09-09
 */
public interface ClassificationMapper extends BaseMapper<Classification> {
    @Select("select * from list_of_goods g INNER JOIN commodity_type t on g.commodity_id = t.commodity_type_id INNER JOIN classification c on t.commodity_category_id = c.category_id and g.list_goods_id = t.commodity_quantity where g.list_goods_id =  #{id}")
    ClassificationVo selectAllByCommodityCategory(@Param("id") Integer id);

    @Select("select * from list_of_goods g INNER JOIN commodity_type t on g.commodity_id = t.commodity_type_id INNER JOIN classification c on t.commodity_category_id = c.category_id and g.list_goods_id = #{id}")
    List<ClassificationVo> selectAllByCommodityId(@Param("id") Integer id);
}
